package com.yeu.action;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionSupport;
import com.yeu.util.ConnectionPool;

public class ResourceAction extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private List<Map<String, String>> result;
	private String departmentId;
	
	public void setDepartmentId(String departmentId) {
		this.departmentId = departmentId;
	}

	public List<Map<String, String>> getResult() {
		return result;
	}

	public String classList(){
		String sql="select * from CLASS";
		result=ConnectionPool.executeQuery(sql);
		return SUCCESS;
	}
	
	public String departmentList(){
		String sql="select * from DEPARTMENT";
		result=ConnectionPool.executeQuery(sql);
		return SUCCESS;
	}
	
	public String leaderList(){
		String sql="select * from USERTABLE U,DEPARTMENTLEADER D where D.DEPARTMENTID=? and U.USERID=D.USERID";
		result=ConnectionPool.executeQuery(sql, departmentId);
		for (Map<String, String> map : result) {
			map.remove("DEPARTMENTID");
			map.remove("PASSWORD");
			map.remove("ROLEID");
		}
		return SUCCESS;
	}
}